import request from '../utils/request';

//查看2021年7月之后和2021年之前的数据
export async function getFolwRunInfo({ runID }) {
    return request(`/api/restricted/workflow/RunInfo/${runID}`);
}
//查看2021年7月之后和2021年之前的数据
export async function fetchFlowRunInfoBak({ runID }) {
    return request(`/api/restricted/workflow/RunInfoBak/${runID}`);
}
export async function getFolwExecutor({ runID }) {
    return request(`/api/restricted/workflow/Executor/${runID}`);
}
export async function setFolwExecutor({ runID, stepID, userIDstr }) {
    let data = new FormData()
    data.append("stepID", stepID)
    data.append("userIDstr", userIDstr)
    return request(`/api/restricted/workflow/Executor/${runID}`, {
        method: 'POST',
        body: data
    });
}

export async function create({ wfid, userID }) {
    let data = new FormData()
    data.append("userID", userID)
    return request(`/api/restricted/workflow/Create/${wfid}`, {
        method: 'POST',
        body: data
    });
}

// export async function batchSubmit({ runIDs, userID, desc, bType }) {
//     let data = new FormData()
//     data.append("runIDs", JSON.stringify(runIDs))
//     data.append("userID", userID)
//     data.append("desc", desc)
//     data.append("bType", bType)
//     return request(`/api/restricted/workflow/BatchSubmit`, {
//         method: 'POST',
//         body: data
//     });
// }
export async function batchSubmit({ runIDs, userID, desc, bType,ishld }) {
    let data = new FormData()
    data.append("runIDs", JSON.stringify(runIDs))
    data.append("userID", userID)
    data.append("desc", desc)
    data.append("bType", bType)
    data.append("ishld", ishld)
    return request(`/api/restricted/workflow/BatchSubmit`, {
        method: 'POST',
        body: data
    });
}

export async function submit({ runID, userID, desc, bType }) {
    let data = new FormData()
    data.append("userID", userID)
    data.append("desc", desc)
    data.append("bType", bType)
    return request(`/api/restricted/workflow/Submit/${runID}`, {
        method: 'POST',
        body: data
    });
}

export async function sendBack({ runID, userID, backStepID, desc }) {
    let data = new FormData()
    data.append("userID", userID)
    data.append("backStepID", backStepID)
    data.append("desc", desc)
    return request(`/api/restricted/workflow/SendBack/${runID}`, {
        method: 'POST',
        body: data
    });
}

export async function abort({ runIDs }) {
    let data = new FormData()
    data.append("runIDs", JSON.stringify(runIDs))
    return request(`/api/restricted/workflow/Abort`, {
        method: 'POST',
        body: data
    });
}

export async function deleteFolw({ runID }) {
    return request(`/api/restricted/workflow/Delete/${runID}`, {
        method: 'POST',
    });
}
//获取是否流程管理员的方法
export async function isManager({ permID }) {
    return request(`/api/restricted/workflow/IsManager/${permID}`, {
        method: 'POST',
    });
}
//获取对公原客户经理占比
export async function fetgetCompAccoDivi({ runID }) {      
    return request(`/api/restricted/workflow/fetgetCompAccoDivi/${runID}`, {
        method: 'POST',
    });   
}
//获取零售原客户经理占比
export async function fetgetIndiAccoDivi({ runID }) {     
    return request(`/api/restricted/workflow/fetgetIndiAccoDivi/${runID}`, {
        method: 'POST',
    });   

}

